import React from 'react'
import classNames from 'classnames'

function getPages() {
    return [...Array(10).keys()]
}

export default (props) => {
    const {
        className,
        pageSize,
        pageIndex,
        totalCount,
        showNext,
        showPrev
    } = props
    const totalPages=Math.ceil(totalCount/pageSize)
    return (
        <div className={classNames("pagination", className)}>
            {showPrev ? <span className="prev-page">上一页</span> : null}
            <ul className="pages">
                {getPages().map((item) =>
                    <li key={item} className={classNames('page-item', {active: pageIndex === item})}>{item + 1}</li>
                )}
            </ul>
            {showNext ? <span className="next-page">下一页</span> : null}
            <span className="pagination-info">
              当前第{pageIndex}页/共{totalPages}页 <span>{totalCount}</span>条记录
            </span>
        </div>)
}
